<?xml version="1.0" encoding="UTF-8"?>
<Configuration name="statica" monitorInterval="600">
    <Properties>
        <property name="app-name">${main:0}</property>
        <property name="log-level">${main:2}</property>
        <property name="file-name">${app-name}</property>
        <property name="logs-dir">logs</property>
        <property name="arch-dir">${logs-dir}/archive</property>
        <property name="log-size">10MB</property>
        <property name="archive-count">10</property>

        <Property name="pattern-console">[%p{length=1}] %m at %l%n</Property>
        <Property name="pattern-file">%date{dd.MM.yy HH:mm.ss_SSS} %t[%p{length=1}] %m at %l%n</Property>
    </Properties>

    <Appenders>
        <Console name="to-console" target="SYSTEM_OUT">
            <PatternLayout pattern="${pattern-console}" charset="${main:1}"/>
            <ThresholdFilter level="${log-level}" onMatch="ACCEPT" onMismatch="DENY"/>
        </Console>

        <RollingFile name="to-file" append="true"
                     fileName="${logs-dir}/${file-name}.log"
                     filePattern="${arch-dir}/${file-name}-%i.log.zip">

            <ThresholdFilter level="${log-level}" onMatch="ACCEPT" onMismatch="DENY"/>
            <PatternLayout pattern="${pattern-file}" charset="UTF-8"/>

            <Policies>
                <SizeBasedTriggeringPolicy size="${log-size}"/>
            </Policies>
            <DefaultRolloverStrategy min="1" max="${archive-count}" fileIndex="min" compressionLevel="9"/>
        </RollingFile>

        <RollingFile name="file-reports" append="true"
                     fileName="${logs-dir}/reports.log"
                     filePattern="${arch-dir}/reports-%i.log.zip">

            <PatternLayout pattern="${pattern-file}" charset="UTF-8"/>

            <Policies>
                <SizeBasedTriggeringPolicy size="${log-size}"/>
            </Policies>
            <DefaultRolloverStrategy min="1" max="${archive-count}" fileIndex="min" compressionLevel="9"/>
        </RollingFile>

        <RollingFile name="file-journal" append="true"
                     fileName="${logs-dir}/journal.log"
                     filePattern="${arch-dir}/journal-%i.log.zip">

            <PatternLayout pattern="${pattern-file}" charset="UTF-8"/>

            <Policies>
                <SizeBasedTriggeringPolicy size="${log-size}"/>
            </Policies>
            <DefaultRolloverStrategy min="1" max="${archive-count}" fileIndex="min" compressionLevel="9"/>
        </RollingFile>

        <RollingFile name="file-server-props" append="true" fileName="config/adminProperties.txt" filePattern="config/adminProperties-%i.zip">
            <PatternLayout pattern="%m%n" charset="UTF-8"/>
            <Policies>
                <SizeBasedTriggeringPolicy size="${log-size}"/>
            </Policies>
            <DefaultRolloverStrategy min="1" max="2" fileIndex="min" compressionLevel="9"/>
        </RollingFile>

        <RollingFile name="file-quser" append="true"
                     fileName="${logs-dir}/quser.log"
                     filePattern="${arch-dir}/quser-%i.log.zip">

            <PatternLayout pattern="${pattern-file}" charset="UTF-8"/>

            <Policies>
                <SizeBasedTriggeringPolicy size="${log-size}"/>
            </Policies>
            <DefaultRolloverStrategy min="1" max="${archive-count}" fileIndex="min" compressionLevel="9"/>
        </RollingFile>


    </Appenders>

    <!--
        server,
    client,
    desktop,
    reception,
    admin,
    welcome,
    hardware_buttons,
    tablo_redactor,
    zone_board,
    quser,

    -->

    <Loggers>


        <Logger name="adminProperties" level="${log-level}" additivity="false">
            <AppenderRef ref="file-server-props"/>
        </Logger>

        <Logger name="ru.apertum.qsystem.reports" level="${log-level}" additivity="false">
            <AppenderRef ref="to-console"/>
            <AppenderRef ref="file-reports"/>
        </Logger>

        <Logger name="ru.apertum.journal" level="${log-level}" additivity="false">
            <AppenderRef ref="to-console"/>
            <AppenderRef ref="file-journal"/>
        </Logger>

        <Logger name="ru.apertum.qsystem" level="${log-level}" additivity="false">
            <AppenderRef ref="to-console"/>
            <AppenderRef ref="to-file"/>
        </Logger>

        <Logger name="ru.apertum.qbot" level="${log-level}" additivity="false">
            <AppenderRef ref="to-console"/>
            <AppenderRef ref="to-file"/>
        </Logger>

        <Root level="info">
            <AppenderRef ref="to-console"/>
        </Root>
    </Loggers>
</Configuration>